<script src="//cdn.ckeditor.com/4.4.6/standard/ckeditor.js"></script>

<?php

include 'cfg.php';

$submit=isset($_POST['submit'])?$_POST['submit']:null;
$title=isset($_POST['title'])?$_POST['title']:null;
$content=isset($_POST['content'])?$_POST['content']:null;

if(($title==null || $content==null) && $submit!=null){
    header('Location: /?m=About');
    exit;
}
if($title!=null && $content!=null){
    $stmt = $dbh->prepare('insert into article (title, content, pubdate) values (?,?,?)',
        array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));

    $stmt->execute(array($title,$content,time()));
    
    header('Location: /');
    exit;
    
}else{
    
    echo '<form method="post" action="input.php"><p><input type="text" name="title" size="60" /></p><p><textarea id="textarea_content" name="content" rows="10" cols="50"></textarea></p><p><input type="submit" name="submit" /></p></form>';
    
}
?>

<script>CKEDITOR.replace( 'textarea_content' );</script>